<th:block th:fragment="process">
<!-- 审批进度显示框 S -->
<div class="modal fade" id="process_modal" role="dialog">
<div class="modal-dialog modal-lg">
 <div class="modal-content">
 
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
	<h4 class="modal-title" id="user_title">审批进度</h4>
</div>

<div class="modal-body">
<div class="row">
<div class="col-md-12">
<ul class="timeline">

</ul></div></div></div>

<div class="modal-footer">
	<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>

</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--审批进度显示框 E -->

<script>
function show_process(id) {
	$(".timeline").empty();
	$.post("[[@{/contract/loginfo}]]", {id: id}, function(ret){
		if(!ret.success) {
			$.dialog.alert(ret.message);
			return;
		}
		var data = ret.message;
		$(".timeline").append(ret.message);
		$("#process_modal").modal({backdrop:'static', keyboard: false});
	}, "json");
}
</script>
</th:block>

<!-- 提交审核对话框 S -->
<th:block th:fragment="apply_audit(url)">
<div class="modal fade" id="apply_audit_modal" role="dialog">
<div class="modal-dialog">
 <div class="modal-content">
 
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
	<h4 class="modal-title" id="apply_title">提交审核</h4>
</div>

<div class="modal-body">
<div class="row">
<div class="col-md-12">
<form action="#" class="form-horizontal" id="apply_audit_form">
	<input type="hidden" id="apply_id" />
	<input type="hidden" id="act" />
	<div class="form-group">
		<label for="describe" class="col-sm-2 control-label">说明</label>
		<div class="col-sm-10">
			<p class="form-control-static" id="node_info"></p>
		</div>
	</div>
	<div class="form-group" id="opers_dev">
		<label for="value" class="col-sm-2 control-label" id="oper_label">审核人</label>
		<div class="col-sm-10">
			<select name="oper_user" id="oper_user" class="form-control" data-rule-required="true">
			</select>
		</div>
	</div>
	<div class="form-group" id="opers_memo">
		<label for="value" class="col-sm-2 control-label" id="oper_label">审批理由</label>
		<div class="col-sm-10">
			<textarea class="form-control" rows="2" id="audit_memo"></textarea>
		</div>
	</div>
</form>
   

</div></div></div>

<div class="modal-footer">
	<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	<button type="button" class="btn btn-primary" onclick="apply_audit_submit();" id="btn_text">提交申请</button>
</div>

</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
//作废申请
function cancel_audit(id) {
	$("#audit_memo").val("");
	$("#act").val('cancel');
	$("#opers_dev").css("display", "block");
	$("#opers_memo").css("display", "none");
	
	$.post("[[@{/apply/cancel}]]", {id: id}, function(ret){
		if(!ret.success) {
			$.dialog.alert(ret.message);
			return;
		}
		$("#apply_id").val(id);
		var data = ret.message.nextNode;
		$("#apply_title").text("申请作废合同");
		$("#node_info").text(data.desc);
		//合同盖章
		if(data.id == 7) {
			$("#oper_label").text("盖章人");	
			$("#opers_memo").css("display", "none");
		} else {
			$("#oper_label").text("审核人");
		}		
		$("#oper_user").empty();
		data.opers.forEach(function(item, index, input) {
			$("#oper_user").append("<option value='" + item.id + "'>" + item.name + "</option>");   
		});
		
		$("#apply_audit_modal").modal({backdrop:'static', keyboard: false});
	}, "json");
}

function apply_audit(id) {
	$("#audit_memo").val("");
	$("#act").val('apply');
	
	$.post("[[@{/apply/apply}]]", {id: id}, function(ret){
		if(!ret.success) {
			$.dialog.alert(ret.message);
			return;
		}
		$("#apply_id").val(id);
		var data = ret.message.nextNode;
		$("#apply_title").text("申请" + data.name);
		$("#node_info").text(data.desc);
		//合同盖章
		if(data.id == 7) {
			$("#oper_label").text("盖章人");	
			$("#opers_memo").css("display", "none");
		} else {
			$("#oper_label").text("审核人");
		}		
		$("#oper_user").empty();
		if(data.opers) {
			$("#opers_dev").css("display", "block");
			data.opers.forEach(function(item, index, input) {
				$("#oper_user").append("<option value='" + item.id + "'>" + item.name + "</option>");   
			});
		} else {
			$("#opers_dev").css("display", "none");
			$("#opers_memo").css("display", "none");
		}
		$("#apply_audit_modal").modal({backdrop:'static', keyboard: false});
	}, "json");
}
function apply_audit_submit() {
	
	var data = {id: $("#apply_id").val(), oper: $("#oper_user").val(), auditMemo: $("#audit_memo").val(), act: $("#act").val()};
	$.post("[[@{/apply/apply/submit}]]", data, function(ret){
		if(ret.success) {
			location.href = '[[@{/} + ${url}]]';
		} else {
			$.dialog.alert(ret.message);
		}
	}, 'json');
}
</script>
</th:block>
<!--提交审核对话框 E -->